Skip to main content

Overview

The encryption module provides functions for encrypting plaintext values (integers) and field elements into PVAC-HFHE ciphertexts. All encryption operations support multi-slot ciphertexts for SIMD-style computation.

Core encryption functions

enc_value

Encrypts a single unsigned 64-bit integer into a ciphertext.
const PubKey&
required
Public key for encryption
const SecKey&
required
Secret key for generating noise
uint64_t
required
The plaintext value to encrypt
Cipher
A ciphertext encrypting the value with depth 0

Description

Encrypts a single integer value using masking and fusion. The plaintext is split into v + m and -m where m is a random mask, then both parts are encrypted and combined. See: encrypt.hpp:740

enc_value_depth

Encrypts a single value with a specific noise budget for a given circuit depth.
const PubKey&
required
Public key for encryption
const SecKey&
required
Secret key for generating noise
uint64_t
required
The plaintext value to encrypt
int
required
Depth hint for noise budget computation
Cipher
A ciphertext with noise budget allocated for depth d

Description

Encrypts a value with noise budget planned for a circuit of depth d. Higher depth values allocate more noise entropy for deeper computations. See: encrypt.hpp:732

enc_values

Encrypts multiple values into a single multi-slot ciphertext.
const PubKey&
required
Public key for encryption
const SecKey&
required
Secret key for generating noise
const std::vector<uint64_t>&
required
Vector of plaintext values to encrypt in parallel slots
Cipher
A multi-slot ciphertext encrypting all values in parallel

Description

Creates a ciphertext with multiple slots, each encrypting one value from the input vector. Enables SIMD-style parallel computation on batched data. See: encrypt.hpp:753

enc_values_depth

Encrypts multiple values with depth-specific noise budget.
const PubKey&
required
Public key for encryption
const SecKey&
required
Secret key for generating noise
const std::vector<uint64_t>&
required
Vector of plaintext values
int
required
Depth hint for noise allocation
Cipher
Multi-slot ciphertext with depth d noise budget
See: encrypt.hpp:744

enc_zero_depth

Encrypts the value zero with a specified noise budget.
const PubKey&
required
Public key for encryption
const SecKey&
required
Secret key for generating noise
int
required
Depth hint for noise budget
Cipher
Ciphertext encrypting zero

Description

Generates a zero ciphertext with fresh noise. Used primarily for bootstrapping and recryption operations to refresh noise without changing the encrypted value. See: encrypt.hpp:757

Field element encryption

enc_fp_depth

Encrypts a field element with specified depth.
const PubKey&
required
Public key
SecKey&
required
Secret key
const Fp&
required
Field element to encrypt
int
required
Depth hint
Cipher
Ciphertext encrypting the field element
See: encrypt.hpp:724

enc_fp_depth (multi-slot)

Encrypts a vector of field elements.
const PubKey&
required
Public key
const SecKey&
required
Secret key
const std::vector<Fp>&
required
Vector of field elements
int
required
Depth hint
Cipher
Multi-slot ciphertext
See: encrypt.hpp:720

Utility functions

combine_ciphers

Combines two ciphertexts into a single ciphertext by fusing their layer graphs.
const PubKey&
required
Public key
const Cipher&
required
First ciphertext
const Cipher&
required
Second ciphertext
Cipher
Fused ciphertext with combined layers and edges

Description

Merges the layer DAGs and edge sets of two ciphertexts. Layer indices from b are offset appropriately. Used internally during encryption and arithmetic operations.
The function automatically compacts edges if the budget is exceeded.
See: encrypt.hpp:728

plan_noise

Computes the noise budget allocation for a given depth.
const PubKey&
required
Public key with parameter set
int
required
Expected circuit depth
std::pair<int, int>
Pair of (n2, n3) where n2 is the number of 2-tuples and n3 is the number of 3-tuples to allocate

Description

Computes the optimal noise budget based on the parameter set’s entropy capacity and the expected circuit depth. The allocation is split between 2-tuples and 3-tuples according to tuple2_fraction. See: encrypt.hpp:643

sigma_density

Computes the sigma vector density of a ciphertext.
const PubKey&
required
Public key
const Cipher&
required
Ciphertext to analyze
double
Density ratio between 0.0 and 1.0

Description

Computes the fraction of set bits across all sigma vectors in the ciphertext. A density near 0.5 indicates well-balanced noise. Values far from 0.5 may indicate the need for recryption. See: encrypt.hpp:648

compact_edges

Compacts the edge set by merging edges with the same layer, index, and sign.
const PubKey&
required
Public key
Cipher&
required
Ciphertext to compact (modified in place)

Description

Reduces the ciphertext size by merging redundant edges. This operation does not change the encrypted value but improves efficiency. See: encrypt.hpp:658

compact_layers

Removes unused layers from the ciphertext.
Cipher&
required
Ciphertext to compact (modified in place)

Description

Removes layers that are not referenced by any edge and updates layer indices accordingly. Reduces memory footprint without affecting the encrypted value. See: encrypt.hpp:662